function uploader(me, url) {
	var me = $(me);
	// 是否能上传多个文件
	var selection = me.attr("selection");
	var buessId = me.attr("buessId");
	if (!selection) {
		$.ajax({
			url : rootpath + '/attachment/checkInfo.do',
			data : {
				GROUP_ID : buessId
			},
			async : false,
			dataType : 'json',
			success : function(data, textStatus, jqXHR) {
				if (data.status == 1) {
					selection = false;
				}
			}
		});
	}
	if (!selection) {
		parent.layer.msg('只能上传一个附件！', {
			time : 1000
		});
		return;
	}
	// 隐藏需要赋值的字段
	var buessInputHiddenTagId = me.attr("buessInputHiddenTagId");
	parent.layer.open({
		title : '文件上传',
		type : 2,
		btn : [ '关闭' ],
		yes : function(index, layero) {
			var iframeWin = layero.find("iframe")[0].contentWindow;
			if (iframeWin.files.length > 0) {
				// 赋值
				$("#" + buessInputHiddenTagId).val(iframeWin.gropId);
				
				var addBtn = "<button class='btn btn-success' id='viewFileBtn' type='button' onclick=viewFileList(this,'" + iframeWin.gropId + "')><i class='ace-icon fa fa-eye bigger-110'></i>查看</button>";
				if (me.next().length > 0 && me.next().attr('id') == 'viewFileBtn') {
					me.next().remove();
				}
	     if(!me.parent().find('#viewFileBtn').length){
		   me.parent().append(addBtn);
					}
				
			}
			parent.layer.close(index);
		},
		area : [ '60%', '50%' ],
		content : url
	});
}

function viewFileList(me, id) {
	var me = $(me);
	parent.layer.open({
		title : '文件查看',
		closeBtn : 0,
		type : 2,
		btn : [ '关闭' ],
		yes : function(index, layero) {
			try {
				var rows = layero.find("iframe")[0].contentWindow.dataTable.datagrid('getRows');
				if (rows.length == 0) {
					me.remove();
					$('#buessInputHiddenTagId').val('');
				}
			} catch (err) {
				parent.layer.close(index);
			}
			parent.layer.close(index);
		},
		area : [ '100%', '100%' ],
		content : rootpath + '/attachment/toViewList.do?GROUP_ID=' + id,
	});
}
